<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>AddMapElement</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">AddMapElement()</font></b></p>
<p><b>Syntax</b></p><blockquote>

Result = <font color="#006666"><b>AddMapElement</b></font>(Map(), Key$ [, Flags])</blockquote>

<b>Description</b><br><blockquote>



Adds a new empty element in the Map() using the specified key. This new element becomes the current 
element of the map. 

 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>Map()</i></td>
<td width="90%"> 
 
The map to which to add the element. 

 

</td></tr>
<tr><td><i>Key$</i></td>
<td> 
 
The key for the new element. 

 

</td></tr>
<tr><td><i>Flags (optional)</i></td>
<td> 
 
Flags can be one of the following values: 
 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Map_ElementCheck</font>  : Checks if an element with a same key already exists, and replaces it (default).
  <font color="#924B72">#PB_Map_NoElementCheck</font>: No element check, so if a previous element with the same key was already present, it 
                      will be not replaced but kept in the map, unreachable with direct access. It will remain unreachable 
                      until the newly added element has been deleted. Such unreachable elements will still be listed when enumerating
                      all the map elements with <a href="../reference/foreach_next.html">ForEach</a> or <a href="nextmapelement.html">NextMapElement()</a>. This mode is faster but also more 
                      error prone, so use it with caution.
</font></pre>

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>



Returns nonzero on success and zero on failure. 
The value returned is a <a href="../reference/memory.html">pointer</a> to the new element data. 

 

</blockquote><p><b>Remarks</b></p><blockquote>



This function isn't mandatory when dealing with maps, as elements are automatically added when affecting a value to them. 

 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">NewMap</font></b> <font color="#006666">Country</font>.s()
  
  <font color="#006666">; Regular way to add an element</font>
<font color="#006666">  Country</font>("US") = "United State"
  
  <font color="#006666">; The same using AddMapElement()</font>
<font color="#006666">  AddMapElement</font>(<font color="#006666">Country</font>(), "FR")
<font color="#006666">  Country</font>() = "France"
  
  <b><font color="#006666">ForEach</font></b> <font color="#006666">Country</font>()
    <b><font color="#006666">Debug</font></b> <font color="#006666">Country</font>()
  <b><font color="#006666">Next</font></b>
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="deletemapelement.html">DeleteMapElement()</a>, <a href="clearmap.html">ClearMap()</a>, <a href="mapsize.html">MapSize()</a> 

</Blockquote><p><b>Supported OS  </b><Blockquote>All</Blockquote></p><center><a href=index.html>Map Index</a> - <a href=clearmap.html>ClearMap()</a> -&gt;



</body></html>